home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
cpp_libs
/
rjs.lha
/
RJS
/
String
/
src
/
StringScan.C
< prev
next >
Wrap
C/C++ Source or Header
|
1991-06-14
|
1KB
|
50 lines
#include "String.h"
const FALSE=0,TRUE=1;
int RJS_StringScan::operator()(RJS_String &match)
{
int curr_pos;
int ss_pos, ss_len;
if ( pos >= str->length()) {
match=NullRJS_String;
if (st==ByField && !lf) { lf=1; return TRUE; }
return FALSE;
}
curr_pos=pos;
switch(st) {
case ByField:
ss_pos=ss->search(str->substr(curr_pos),ss_len);
if (ss_len==0) { // no more fields, return rest of string
pos+=str->length()-curr_pos;
match=str->substr(curr_pos);
lf=1; // set last field flag
return TRUE;
}
if (ss_pos!=0) {
pos += ss_pos+ss_len;
match=str->substr(curr_pos,ss_pos);
return TRUE;
} else { // null field
pos += ss_len;
match=NullRJS_String;
return TRUE;
}
break ;
case ByMatch:
ss_pos=ss->search(str->substr(curr_pos),ss_len);
if (ss_len==0) { match=NullRJS_String; return FALSE; }
curr_pos+=ss_pos;
pos = curr_pos+ss_len;
match=str->substr(curr_pos,ss_len);
return TRUE;
//break;
default:
match=NullRJS_String;
return FALSE;
} // eos
}